#ifndef NFCCLIENT_H
#define NFCCLIENT_H

// INCLUDES
#include <e32std.h>
#include <e32base.h>

#include "NdefMessageObserver.h"
#include "scatu/Utils.h"

// CLASS DECLARATION

class CNdefMessageListener;

using scatu::MFunctor;

/**
 *  CNfcClient
 * 
 */
class CNfcClient : public CBase, public MNDefMessageObserver
    {
public:
    ~CNfcClient();
    static CNfcClient* NewL();
    static CNfcClient* NewLC();
    
public:
    
    void ReadTagAsyncL(MFunctor<HBufC8 *> & aRet, TDesC8 const & aTnf, TDesC8 const & aType, TInt aTimeout);
    void SetForegroundL(TBool aOnForeground);
    
private:
    CNfcClient();
    void ConstructL();
    
private: // MNDefMessageObserver implementation
    void NDefMessageReceivedL(RNdefMessageHandle & aMessage);
    void NDefMessageReceptionFailedL();
    
private:
    void CancelTagRead();
    void CloseReceivedMessage();
    HBufC8 * ReceivedMessageToBufL();
    
    static TInt CancelTagReadCallback(TAny * aThis);
    
private:
    
    CNdefMessageListener * iMessageListener;
    RNdefMessageHandle * iReceivedMessage;
    MFunctor<HBufC8 *> * iMessageReturnFunctor;
    
    // Timeout timer for all synchronous calls
    CPeriodic * iSynchronousCallTimeout;

    };

#endif // NFCCLIENT_H
